#include "elinputnumber.h"
#include <QDoubleSpinBox>
#include <QPaintEvent>
#include <QPainter>
#include "../basic/eltheme.h"

ElInputNumber::ElInputNumber(QWidget *parent)
    : ElComponent{parent}
{
    _doubleInput = new QDoubleSpinBox(this);
    _doubleInput->setFrame(false);
    _doubleInput->setButtonSymbols(QAbstractSpinBox::NoButtons);
}

bool ElInputNumber::event(QEvent *e)
{
    if (e->type() == QEvent::EnabledChange) {
        _palette.toggleColorGroup(isEnabled() ? ElPalette::Normal : ElPalette::Disabled);
        update();
    }
    return ElComponent::event(e);
}

void ElInputNumber::initPalette()
{
    _palette.setColor(ElPalette::Border, ThemeColor::textDisabledColor);
    _palette.setColor(ElPalette::Entered, ElPalette::Border, ThemeColor::textDisabledColor);
    // Pressed means focusing in
    _palette.setColor(ElPalette::Pressed, ElPalette::Border, ThemeColor::infoColor);
    _palette.setColor(ElPalette::Disabled, ElPalette::Background, QColor(245, 247, 250));
    _palette.setColor(ElPalette::Disabled, ElPalette::Border, ThemeColor::textDisabledColor);
}
